package com.touni.designpattern.singletonpattern.lazy;

/**
 * @ClassName : DoubleCheckedHungrySingleton
 * @Description : DCL  双检锁机制  性能较好 懒加载
 * @Author : lwq
 * @Date: 2020-10-19 15:29
 */
public class DoubleCheckedSingleton {

    private volatile static DoubleCheckedSingleton doubleCheckedSingleton;

    private DoubleCheckedSingleton(){}

    public static DoubleCheckedSingleton getInstance(){
        if (doubleCheckedSingleton == null){
            synchronized (DoubleCheckedSingleton.class){
                if (doubleCheckedSingleton == null){
                    doubleCheckedSingleton = new DoubleCheckedSingleton();
                }
            }
        }
        return doubleCheckedSingleton;
    }

}
